clear all 
capture log close
set more off

global data "/Users/ceweber/Dropbox/JPAM_TIV_code/original_data/"
global dta "/Users/ceweber/Dropbox/JPAM_TIV_code/dta_files/"
global dataclean "/Users/ceweber/Dropbox/JPAM_TIV_code/dta_output/"
global output "/Users/ceweber/Dropbox/JPAM_TIV_code/output/"

cd "$dataclean"
use  incidence_procanal_firstdiff_monthly.dta, clear
*use  incidence_procanal_noinvid_part2.dta, clear

cd "$output"

****TABLE 3 (MONTHLY PORTION):
gen month4202015=monthly==663
gen month4202016=monthly==675
eststo tab3reg1: reghdfe pricediff6 taxdiff  month420*  if abs(run)<=6  [aw=weight5] , absorb(group_s##procloc##salesloc) vce(cluster procloc salesloc)
 count if pricediff6<.& abs(run)<=6 
 eststo pltab2reg1: reghdfe pricediff6  placebodiff month420*    if abs(prun)<=6 [aw=weight5] , absorb(group_s##procloc##salesloc) vce(cluster procloc salesloc)
  count if pricediff6<.& abs(prun)<=6


*COEFPLOTS WITH LEADS AND LAGS (FIGURE A.3): 
set more off
eststo tab3reg1: reghdfe pricediff6  L3taxdiff L2taxdiff   taxdiff  Ftaxdiff F2taxdiff F3taxdiff L4group F4TaxChange Ltaxdiff  if abs(run)<=6  [aw=weight5] , absorb(group_s##procloc##salesloc) vce(cluster procloc salesloc)
coefplot ,  graphregion(color(white)) bgcolor(white) xtitle({bf: Tax Reform Coefficients by Time}) ytitle({bf:First-Differenced Estimates})   title({bf:Manufacturer Event Study}) ///
    vertical yline(0, lpattern(dash) lcolor(black))  keep(Ltaxdiff taxdiff Ftaxdiff F2taxdiff F3taxdiff)   order(L3taxdiff L2taxdiff Ltaxdiff taxdiff Ftaxdiff F2taxdiff F3taxdiff) ///
	coeflabels(L3taxdiff="t - 3" L2taxdiff  ="t - 2" Ltaxdiff= "t - 1" taxdiff = "t" Ftaxdiff= "t + 1" F2taxdiff="t + 2" F3taxdiff="t + 3" ) omitted
	*title({bf: Processor Price Bandwidth Checks} , color(black))
gr export  proc_pricediff_monthly.png, replace as(png)

*placebo version:
eststo tab3reg1: reghdfe pricediff6  L3placebodiff L2placebodiff   placebodiff  Fplacebodiff F2placebodiff F3placebodiff L4placebogroup F4Placebo Lplacebodiff   if abs(prun)<=6  [aw=weight5] , absorb(group_s##procloc##salesloc) vce(cluster procloc salesloc)
coefplot ,  graphregion(color(white)) bgcolor(white) xtitle({bf: Placebo Coefficients by Time}) ytitle({bf:First-Differenced Estimates})   title({bf:Manufacturer Placebo Event Study}) ///
    vertical yline(0, lpattern(dash) lcolor(black))  keep(  Lplacebodiff placebodiff Fplacebodiff F2placebodiff F3placebodiff) order(L3placebodiff L2placebodiff Lplacebodiff placebodiff Fplacebodiff F2placebodiff F3placebodiff) ///
coeflabels(L3placebodiff="t - 3" L2placebodiff  ="t - 2" Lplacebodiff= "t - 1" placebodiff = "t" Fplacebodiff= "t + 1" F2placebodiff="t + 2" F3placebodiff="t + 3" ) omitted
gr export  proc_pricediffplacebo_monthly.png, replace as(png)
	
****HISTOGRAM (FIGURE A.1):
eststo tab5reg1: reghdfe pricediff6 taxdiff   if abs(run)<=6  [aw=weight5] , absorb(group_s##procloc##salesloc) vce(cluster procloc salesloc)
gen samplehist=e(sample)
twoway (hist pricediff6 if taxdiff==0&(pricediff6)<=1&pricediff6>=-1&abs(run)<=6&samplehist==1, start(-1.02) frac lcolor(gs12) fcolor(gs12) width(.04)) ///
 (hist pricediff6 if taxdiff==1&(pricediff6)<=1&pricediff6>=-1&abs(run)<=6&samplehist==1, start(-1.02) frac width(.04) fcolor(none) lcolor(green)), title({bf: Histogram of Monthly Manufacturer Price Changes}) xtitle({bf:Change in Log Monthly Manufacturer Price}) ytitle({bf: Fraction}) ///
 xline(0, lpattern(dash) lcolor(gs8)) graphregion(color(white)) bgcolor(white) xline(-.198, lpattern(dash) lcolor(gs8)) xline(-.287, lpattern(shortdash) lcolor(gs12)) legend(label(1 "No Reform") label(2 "Reform") )
gr export  hist_procpricediff_monthly.png, replace as(png)
count if pricediff6<-.198 &taxdiff==0&(pricediff6)<=1&pricediff6>=-1&abs(run)<=6&samplehist==1
count if taxdiff==0&(pricediff6)<=1&pricediff6>=-1&abs(run)<=6&samplehist==1
di  3179/18430
  
